package org.pizza.elastic.autoconfigure;

import org.elasticsearch.client.RestHighLevelClient;
import org.frameworkset.elasticsearch.boot.BBossESAutoConfiguration;
import org.pizza.elastic.core.client.ESClient;
import org.springframework.boot.autoconfigure.AutoConfigureAfter;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.boot.autoconfigure.elasticsearch.ElasticsearchRestClientAutoConfiguration;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @author: fyh
 * @date: 2023/3/7
 */
@ConditionalOnClass(RestHighLevelClient.class)
@Configuration(proxyBeanMethods = false)
@AutoConfigureAfter({ElasticsearchRestClientAutoConfiguration.class, BBossESAutoConfiguration.class})
public class ElasticAutoConfiguration {

    @Bean
    public ESClient esClient(RestHighLevelClient restHighLevelClient){
        return new ESClient(restHighLevelClient);
    }
}
